const fs = require("fs");

//读
const read = (path) => {
    return new Promise((resolve, reject) => {
        fs.readFile(path, (err, data) => {
            if (!err) {
                resolve(data.toString());
            }
            reject(err);
        })
    })
}
//写
const write = (path, data) => {
    return new Promise((resolve, reject) => {
        fs.writeFile(path, data, (err) => {
            if (!err) {
                resolve(true);
            }
            reject(false);
        })
    })
}

//暴露模块
module.exports = { read, write };
